package com.site.blog.my.core.controller.admin;

import com.site.blog.my.core.entity.AdminUser;
import com.site.blog.my.core.service.AdminUserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * @ClassName: my-blog
 * @description:
 * @author: zxf
 * @create: 2021-06-30 15:09
 **/
@Controller
public class TestController {

    @Resource
    private AdminUserService adminUserService;
    // 测试接口
    @GetMapping("/test")
    public String test(HttpSession session){
        AdminUser user = adminUserService.getUserDetailById(1);
        session.setAttribute("loginUser", user.getNickName());
        session.setAttribute("loginUserId", user.getAdminUserId());
        //session过期时间设置为7200秒 即两小时
        session.setMaxInactiveInterval(60 * 60 * 2);
        return "redirect:/admin/index";
    }
}

